<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_PilotProjetRol extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idprojetrole;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_RolePersonneIdrolepersonne;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_PILOTPROJECTIdPILOTPROJECT;


    /**
     * Parent relation fk_PILOT_PROJET_ROL_PILOT_PROJECT1
     *
     * @var Application_Model_PilotProject
     */
    protected $_PilotProject;

    /**
     * Parent relation fk_PILOT_PROJET_ROL_role_personne1
     *
     * @var Application_Model_RolePersonne
     */
    protected $_RolePersonne;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idprojetrole'=>'Idprojetrole',
            'role_personne_idrolepersonne'=>'RolePersonneIdrolepersonne',
            'PILOT_PROJECT_idPILOT_PROJECT'=>'PILOTPROJECTIdPILOTPROJECT',
        ));

        $this->setParentList(array(
            'FkPILOTPROJETROLPILOTPROJECT1'=> array(
                    'property' => 'PilotProject',
                    'table_name' => 'PilotProject',
                ),
            'FkPILOTPROJETROLRolePersonne1'=> array(
                    'property' => 'RolePersonne',
                    'table_name' => 'RolePersonne',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column idprojetrole
     *
     * @param int $data
     * @return Application_Model_PilotProjetRol
     */
    public function setIdprojetrole($data)
    {
        $this->_Idprojetrole = $data;
        return $this;
    }

    /**
     * Gets column idprojetrole
     *
     * @return int
     */
    public function getIdprojetrole()
    {
        return $this->_Idprojetrole;
    }

    /**
     * Sets column role_personne_idrolepersonne
     *
     * @param int $data
     * @return Application_Model_PilotProjetRol
     */
    public function setRolePersonneIdrolepersonne($data)
    {
        $this->_RolePersonneIdrolepersonne = $data;
        return $this;
    }

    /**
     * Gets column role_personne_idrolepersonne
     *
     * @return int
     */
    public function getRolePersonneIdrolepersonne()
    {
        return $this->_RolePersonneIdrolepersonne;
    }

    /**
     * Sets column PILOT_PROJECT_idPILOT_PROJECT
     *
     * @param int $data
     * @return Application_Model_PilotProjetRol
     */
    public function setPILOTPROJECTIdPILOTPROJECT($data)
    {
        $this->_PILOTPROJECTIdPILOTPROJECT = $data;
        return $this;
    }

    /**
     * Gets column PILOT_PROJECT_idPILOT_PROJECT
     *
     * @return int
     */
    public function getPILOTPROJECTIdPILOTPROJECT()
    {
        return $this->_PILOTPROJECTIdPILOTPROJECT;
    }

    /**
     * Sets parent relation PILOTPROJECTIdPILOTPROJECT
     *
     * @param Application_Model_PilotProject $data
     * @return Application_Model_PilotProjetRol
     */
    public function setPilotProject(Application_Model_PilotProject $data)
    {
        $this->_PilotProject = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idPILOT_PROJECT'];
        }

        $this->setPILOTPROJECTIdPILOTPROJECT($primary_key);

        return $this;
    }

    /**
     * Gets parent PILOTPROJECTIdPILOTPROJECT
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_PilotProject
     */
    public function getPilotProject($load = true)
    {
        if ($this->_PilotProject === null && $load) {
            $this->getMapper()->loadRelated('FkPILOTPROJETROLPILOTPROJECT1', $this);
        }

        return $this->_PilotProject;
    }

    /**
     * Sets parent relation RolePersonneIdrolepersonne
     *
     * @param Application_Model_RolePersonne $data
     * @return Application_Model_PilotProjetRol
     */
    public function setRolePersonne(Application_Model_RolePersonne $data)
    {
        $this->_RolePersonne = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idrolepersonne'];
        }

        $this->setRolePersonneIdrolepersonne($primary_key);

        return $this;
    }

    /**
     * Gets parent RolePersonneIdrolepersonne
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_RolePersonne
     */
    public function getRolePersonne($load = true)
    {
        if ($this->_RolePersonne === null && $load) {
            $this->getMapper()->loadRelated('FkPILOTPROJETROLRolePersonne1', $this);
        }

        return $this->_RolePersonne;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_PilotProjetRol
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_PilotProjetRol());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_PilotProjetRol::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdprojetrole() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idprojetrole = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdprojetrole()));
    }
}
